package flc.ast.adapter;

import android.graphics.Color;
import android.view.View;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.MyClothesBean;
import flc.ast.bean.MyColorBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class ClothesAdapter extends StkProviderMultiAdapter<MyClothesBean> {

    public ClothesAdapter() {
        addItemProvider(new StkSingleSpanProvider(30));
        addItemProvider(new ClothesProvider());
    }

    private class ClothesProvider extends BaseItemProvider<MyClothesBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_clothes;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, MyClothesBean bean) {
            baseViewHolder.setImageResource(R.id.ivClothesImg, bean.getClothesIcon());
            if (baseViewHolder.getBindingAdapterPosition() == 0) {
                baseViewHolder.getView(R.id.ivClothesInitial).setVisibility(View.VISIBLE);
                baseViewHolder.getView(R.id.ivClothesImg).setVisibility(View.GONE);
            } else {
                baseViewHolder.getView(R.id.ivClothesInitial).setVisibility(View.GONE);
                baseViewHolder.getView(R.id.ivClothesImg).setVisibility(View.VISIBLE);
            }
            if (bean.isSelected()) {
                baseViewHolder.setBackgroundResource(R.id.flClothesItem, R.drawable.xzztk);
            } else {
                baseViewHolder.setBackgroundColor(R.id.flClothesItem, Color.parseColor("#66B6B6B6"));
            }
        }
    }
}
